package com.share.design.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * author:caifan
 * date:2020/2/4
 */
public class DynamicProxy implements InvocationHandler {
    private Object object;

    public DynamicProxy(Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(String.format("before dynamic method name: %s", method.getName()));
        method.invoke(object, args);
        System.out.println(String.format("after dynamic method name: %s", method.getName()));
        return null;
    }
}
